package com.elai.overview.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elai.common.annotation.Log;
import com.elai.common.core.controller.BaseController;
import com.elai.common.core.domain.AjaxResult;
import com.elai.common.enums.BusinessType;
import com.elai.overview.domain.MyChartType;
import com.elai.overview.service.IMyChartTypeService;
import com.elai.common.utils.poi.ExcelUtil;
import com.elai.common.core.page.TableDataInfo;

/**
 * 图标类型Controller
 * 
 * @author elai
 * @date 2021-08-29
 */
@RestController
@RequestMapping("/overview/type")
public class MyChartTypeController extends BaseController
{
    @Autowired
    private IMyChartTypeService myChartTypeService;

    /**
     * 查询图标类型列表
     */
    @PreAuthorize("@ss.hasPermi('overview:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyChartType myChartType)
    {
        List<MyChartType> list = myChartTypeService.selectMyChartTypeList(myChartType);
        return getDataTable(list);
    }

    /**
     * 导出图标类型列表
     */
    @PreAuthorize("@ss.hasPermi('overview:type:export')")
    @Log(title = "图标类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyChartType myChartType)
    {
        List<MyChartType> list = myChartTypeService.selectMyChartTypeList(myChartType);
        ExcelUtil<MyChartType> util = new ExcelUtil<MyChartType>(MyChartType.class);
        return util.exportExcel(list, "图标类型数据");
    }

    /**
     * 获取图标类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('overview:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(myChartTypeService.selectMyChartTypeById(id));
    }

    /**
     * 新增图标类型
     */
    @PreAuthorize("@ss.hasPermi('overview:type:add')")
    @Log(title = "图标类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyChartType myChartType)
    {
        return toAjax(myChartTypeService.insertMyChartType(myChartType));
    }

    /**
     * 修改图标类型
     */
    @PreAuthorize("@ss.hasPermi('overview:type:edit')")
    @Log(title = "图标类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyChartType myChartType)
    {
        return toAjax(myChartTypeService.updateMyChartType(myChartType));
    }

    /**
     * 删除图标类型
     */
    @PreAuthorize("@ss.hasPermi('overview:type:remove')")
    @Log(title = "图标类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(myChartTypeService.deleteMyChartTypeByIds(ids));
    }
}
